home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Internet Strate…Tools for the Enterprise / Microsoft Internet Strategy & Tools for the Enterprise.iso / content / devel.tls / icp / httpexpl.exe / FRMHTTP.FRM (.txt) < prev    next >
Visual Basic Form  |  1996-03-11  |  13KB  |  372 lines

  1. VERSION 4.00
  2. Begin VB.Form frmHTTPExplorer 
  3.    Caption         =   "Internet HTTP Explorer"
  4.    ClientHeight    =   6825
  5.    ClientLeft      =   1080
  6.    ClientTop       =   1485
  7.    ClientWidth     =   9030
  8.    Height          =   7230
  9.    Icon            =   "frmHTTP.frx":0000
  10.    Left            =   1020
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    ScaleHeight     =   6825
  14.    ScaleWidth      =   9030
  15.    Top             =   1140
  16.    Width           =   9150
  17.    Begin VB.Timer tmrIcons 
  18.       Left            =   9120
  19.       Top             =   3360
  20.    End
  21.    Begin VB.PictureBox SizeBar 
  22.       BorderStyle     =   0  'None
  23.       Height          =   6075
  24.       Left            =   4320
  25.       MousePointer    =   9  'Size W E
  26.       ScaleHeight     =   6075
  27.       ScaleWidth      =   30
  28.       TabIndex        =   3
  29.       Top             =   390
  30.       Width           =   30
  31.    End
  32.    Begin VB.Image picFlag 
  33.       BorderStyle     =   1  'Fixed Single
  34.       Height          =   375
  35.       Left            =   8610
  36.       Picture         =   "frmHTTP.frx":0442
  37.       Stretch         =   -1  'True
  38.       Top             =   0
  39.       Width           =   420
  40.    End
  41.    Begin PicClip.PictureClip Flags 
  42.       Left            =   9120
  43.       Top             =   3930
  44.       _Version        =   65536
  45.       _ExtentX        =   11456
  46.       _ExtentY        =   661
  47.       _StockProps     =   0
  48.       Cols            =   18
  49.       Picture         =   "frmHTTP.frx":0B40
  50.    End
  51.    Begin RichtextLib.RichTextBox txtHTTP 
  52.       Height          =   5745
  53.       Left            =   4350
  54.       TabIndex        =   5
  55.       Top             =   690
  56.       Width           =   4635
  57.       _Version        =   65536
  58.       _ExtentX        =   8176
  59.       _ExtentY        =   10134
  60.       _StockProps     =   69
  61.       BackColor       =   -2147483643
  62.       ScrollBars      =   3
  63.       TextRTF         =   $"frmHTTP.frx":3A26
  64.    End
  65.    Begin HTTPCTLib.HTTPCT HTTP 
  66.       Left            =   9060
  67.       Top             =   2670
  68.       _ExtentX        =   847
  69.       _ExtentY        =   847
  70.       RemoteHost      =   "127.0.0.1"
  71.       RemotePort      =   80
  72.       ConnectTimeout  =   0
  73.       RecvTimeout     =   0
  74.       NotificationMode=   1
  75.       Document        =   ""
  76.       Method          =   1
  77.    End
  78.    Begin VB.Label lblStatus 
  79.       BorderStyle     =   1  'Fixed Single
  80.       Height          =   255
  81.       Left            =   4350
  82.       TabIndex        =   4
  83.       Top             =   390
  84.       Width           =   4665
  85.    End
  86.    Begin ComctlLib.ImageList imgIcons 
  87.       Left            =   9030
  88.       Top             =   2070
  89.       _Version        =   65536
  90.       _ExtentX        =   1005
  91.       _ExtentY        =   1005
  92.       _StockProps     =   1
  93.       BackColor       =   -2147483643
  94.       ImageWidth      =   16
  95.       ImageHeight     =   16
  96.       MaskColor       =   12632256
  97.       NumImages       =   4
  98.       i1              =   "frmHTTP.frx":3B09
  99.       i2              =   "frmHTTP.frx":4000
  100.       i3              =   "frmHTTP.frx":44F7
  101.       i4              =   "frmHTTP.frx":49EE
  102.    End
  103.    Begin ComctlLib.ImageList imgTools 
  104.       Left            =   9030
  105.       Top             =   1380
  106.       _Version        =   65536
  107.       _ExtentX        =   1005
  108.       _ExtentY        =   1005
  109.       _StockProps     =   1
  110.       BackColor       =   -2147483643
  111.       ImageWidth      =   16
  112.       ImageHeight     =   16
  113.       MaskColor       =   12632256
  114.       NumImages       =   1
  115.       i1              =   "frmHTTP.frx":4EE5
  116.    End
  117.    Begin ComctlLib.TreeView Tree 
  118.       Height          =   6075
  119.       Left            =   0
  120.       TabIndex        =   2
  121.       Top             =   390
  122.       Width           =   4305
  123.       _Version        =   65536
  124.       _ExtentX        =   7594
  125.       _ExtentY        =   10716
  126.       _StockProps     =   196
  127.       Appearance      =   1
  128.       HideSelection   =   0   'False
  129.       ImageList       =   "imgIcons"
  130.       Indentation     =   441
  131.       LabelEdit       =   1
  132.       PathSeparator   =   "\"
  133.       Style           =   7
  134.    End
  135.    Begin ComctlLib.StatusBar Status 
  136.       Align           =   2  'Align Bottom
  137.       Height          =   345
  138.       Left            =   0
  139.       TabIndex        =   0
  140.       Top             =   6480
  141.       Width           =   9030
  142.       _Version        =   65536
  143.       _ExtentX        =   15928
  144.       _ExtentY        =   609
  145.       _StockProps     =   68
  146.       AlignSet        =   -1  'True
  147.       SimpleText      =   ""
  148.       _timers         =   2
  149.       NumPanels       =   4
  150.       i1              =   "frmHTTP.frx":52A4
  151.       i2              =   "frmHTTP.frx":5393
  152.       i3              =   "frmHTTP.frx":549F
  153.       i4              =   "frmHTTP.frx":55F3
  154.    End
  155.    Begin ComctlLib.Toolbar Tools 
  156.       Height          =   390
  157.       Left            =   0
  158.       TabIndex        =   1
  159.       Top             =   0
  160.       Width           =   8565
  161.       _Version        =   65536
  162.       _ExtentX        =   15108
  163.       _ExtentY        =   688
  164.       _StockProps     =   96
  165.       ImageList       =   "imgTools"
  166.       NumButtons      =   2
  167.       i1              =   "frmHTTP.frx":5743
  168.       i2              =   "frmHTTP.frx":58E2
  169.       AlignSet        =   -1  'True
  170.    End
  171. Attribute VB_Name = "frmHTTPExplorer"
  172. Attribute VB_Creatable = False
  173. Attribute VB_Exposed = False
  174. Option Explicit
  175. Public CurrentNode As Node
  176. Public CurrentURL As String
  177. Public httpDoc As String
  178. Public httpDocName As String
  179. Private Sub Form_Load()
  180.     Dim i As Long
  181.     Set CurrentNode = Tree.Nodes.Add(, , HTTPROOT, HTTPROOT, icoWORLDWIDEWEB)
  182. End Sub
  183. '------------------------------------------------------------
  184. Private Sub Form_Resize()
  185. '------------------------------------------------------------
  186.     Dim W As Long
  187.     Dim H As Long
  188. '------------------------------------------------------------
  189.     picFlag.Left = Me.ScaleWidth - picFlag.Width
  190.     Tools.Width = picFlag.Left
  191.     H = Abs(Me.ScaleHeight - Status.Height - Tools.Height)
  192.     Tree.Height = H
  193.     SizeBar.Height = H
  194.     W = Abs(Me.ScaleWidth - SizeBar.Left - SizeBar.Width)
  195.     lblStatus.Width = W
  196.     With txtHTTP
  197.         .Move .Left, .Top, W, Abs(H - .Top + lblStatus.Top)
  198.     End With
  199. '------------------------------------------------------------
  200. End Sub
  201. '------------------------------------------------------------
  202. '------------------------------------------------------------
  203. Private Sub HTTP_DocOutput(ByVal DocOutput As DocOutput)
  204. '------------------------------------------------------------
  205.     Dim URL As String
  206.     Dim EXT As String
  207.     Dim cNode As Node
  208.     Dim vData As Variant
  209. '------------------------------------------------------------
  210.     Select Case DocOutput.State
  211.     Case icDocBegin
  212.         Screen.MousePointer = vbHourglass
  213.         httpDoc = ""
  214.         tmrIcons.Interval = 200
  215.     Case icDocHeaders
  216.     Case icDocData
  217.         Debug.Print "Bytes: " & Str$(DocOutput.BytesTransferred) & "/" & _
  218.                                 Str$(DocOutput.BytesTotal)
  219.         
  220.         If (httpDocName = "") Then
  221.             DocOutput.GetData vData
  222.             httpDoc = httpDoc & vData
  223.         End If
  224.     Case icDocEnd
  225.         If (httpDocName = "") Then
  226.             txtHTTP.Text = httpDoc
  227.             On Error Resume Next
  228.             Set cNode = Tree.Nodes.Add(Tree.Nodes(1).Key, tvwChild, CurrentURL, CurrentURL, icoWEBDOC)
  229.             If (cNode Is Nothing) Then Set cNode = Tree.Nodes(CurrentURL)
  230.             cNode.Expanded = True
  231.             
  232.             If (cNode.Children = 0) Then
  233.                 Call AddURLDocToTree(Tree, cNode, httpDoc)
  234.             End If
  235.         End If
  236.         httpDoc = ""
  237.         tmrIcons.Interval = 0
  238.         Screen.MousePointer = vbDefault
  239.     Case Else
  240.         HTTP.URL = ""
  241.         httpDoc = ""
  242.         httpDocName = ""
  243.         tmrIcons.Interval = 0
  244.         Screen.MousePointer = vbDefault
  245.     End Select
  246. '------------------------------------------------------------
  247. End Sub
  248. '------------------------------------------------------------
  249. Private Sub HTTP_ProtocolStateChanged(ByVal ProtocolState As Integer)
  250.     Status.Panels(2).Text = HTTP.ProtocolStateString
  251. End Sub
  252. Private Sub HTTP_StateChanged(ByVal State As Integer)
  253.     Status.Panels(1).Text = HTTP.StateString
  254. End Sub
  255. '------------------------------------------------------------
  256. Private Sub SizeBar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  257. '------------------------------------------------------------
  258.     If (Button = vbLeftButton) Then                 ' If Left Button Down
  259.         SizeBar.Left = SizeBar.Left + X             ' Move Size Bar
  260.         Me.Refresh                                  ' Refresh improves appearence
  261.     End If
  262. '------------------------------------------------------------
  263. End Sub
  264. '------------------------------------------------------------
  265. '------------------------------------------------------------
  266. Private Sub SizeBar_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  267. '------------------------------------------------------------
  268.     Dim L As Long, W As Long, SW As Long
  269.     Dim L2 As Long, W2 As Long
  270. '------------------------------------------------------------
  271.     With SizeBar
  272.         L = .Left
  273.         W = .Width
  274.         SW = Me.ScaleWidth
  275.         
  276.         If (L < W) Then                             ' Outside Left Of Window
  277.             L = W                                   ' Fix Position
  278.             .Left = L                               ' Adjust sizebar position
  279.         ElseIf (L > SW) Then                        ' Outside Right Of Window
  280.             L = SW - W                              ' Fix Position
  281.             .Left = L                               ' Adjust sizebar position
  282.         End If
  283.         
  284.         Tree.Width = Abs(L - Tree.Left)             ' Resize TreeView Width
  285.         L2 = L + W
  286.         W2 = Abs(SW - L - W)
  287.         
  288.         lblStatus.Move L2, lblStatus.Top, W2
  289.         txtHTTP.Move L2, txtHTTP.Top, W2
  290.     End With
  291. '------------------------------------------------------------
  292. End Sub
  293. '------------------------------------------------------------
  294. Private Sub tmrIcons_Timer()
  295.     Static pic As Long
  296.     picFlag.Picture = Flags.GraphicCell(pic)
  297.     picFlag.Refresh
  298.     pic = (pic + 1) Mod Flags.Cols
  299. End Sub
  300. '------------------------------------------------------------
  301. Private Sub Tools_ButtonClick(ByVal Button As Button)
  302. '------------------------------------------------------------
  303.     Dim URL As String
  304.     Dim defURL As String
  305.     Dim msg As String
  306.     Dim Title As String
  307. '------------------------------------------------------------
  308.     Select Case Button.Index
  309.     Case btnGLOBESEARCH
  310.         msg = "Please enter a valid URL address..."
  311.         Title = "Explore a new internet address..."
  312.         defURL = "http://www.microsoft.com/"
  313.         URL = InputBox(msg, Title, defURL)
  314.         
  315.         If (URL <> "") Then
  316.             URL = LCase$(URL)
  317.             If (Left$(URL, 7) <> "http://") Then URL = "http://" & URL
  318.             If (Right$(URL, 1) <> "/") Then URL = URL & "/"
  319.             
  320.             CurrentURL = URL
  321.             HTTP.GetDoc CurrentURL
  322.         End If
  323.     End Select
  324. '------------------------------------------------------------
  325. End Sub
  326. '------------------------------------------------------------
  327. '------------------------------------------------------------
  328. Private Sub Tree_NodeClick(ByVal Node As Node)
  329. '------------------------------------------------------------
  330.     Dim EXT As String
  331. '------------------------------------------------------------
  332.     If ((Node <> CurrentNode) And (Node.Key <> HTTPROOT)) Then
  333.         Set CurrentNode = Node
  334.         CurrentURL = LCase(Node.Key)
  335.         lblStatus.Caption = CurrentURL
  336.         
  337.         If (Left$(Right$(CurrentURL, 4), 1) = ".") Then EXT = Right$(CurrentURL, 3)
  338.         
  339.         Select Case EXT
  340.         Case "zip", "exe", "txt", "doc", _
  341.              "gif", "jpg", "avi", "wav"         ' Download extentions...
  342.             Call GetTempFileFromURL(CurrentURL, httpDocName)
  343.             
  344.             HTTP.GetDoc CurrentURL, , httpDocName
  345.             Do While ((HTTP.DocOutput.State = icDocBegin) Or _
  346.                       (HTTP.DocOutput.State = icDocData) Or _
  347.                       (HTTP.DocOutput.State = icDocHeaders))
  348.                 DoEvents
  349.             Loop
  350.             
  351.             Load frmConfirm
  352.             frmConfirm.lblFileName.Caption = "" & "(" & UCase(EXT) & ")"
  353.             frmConfirm.Show vbModal
  354.             
  355.             Select Case frmConfirm.Tag
  356.             Case CStr(vbOK)
  357.                 Call ShellURLDoc(Me.hWnd, httpDocName)
  358.             Case CStr(vbCancel)
  359.             Case Else
  360.                 If (Dir$(frmConfirm.Tag) <> "") Then Kill frmConfirm.Tag
  361.                 Name httpDocName As frmConfirm.Tag
  362.             End Select
  363.             httpDocName = ""
  364.             Unload frmConfirm
  365.         Case Else
  366.             HTTP.GetDoc CurrentURL
  367.         End Select
  368.     End If
  369. '------------------------------------------------------------
  370. End Sub
  371. '------------------------------------------------------------
  372.